package com.gosophia.roleManagement.action;

import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.bean.RequestResult;
import com.gosophia.userManagement.dto.PermissionDTO;
import com.gosophia.userManagement.ws.UserManagementWebService;
import com.opensymphony.xwork2.ActionSupport;

@Scope("prototype")
@Controller("GetNullPermissionTreeAction")
public class GetNullPermissionTreeAction extends BaseSupportAction{

	private String permissionTree = "";

	@Autowired
	private UserManagementWebService userManagementWebService;

	@Override
	public String _execute() throws Exception {
		List<PermissionDTO> permissions = userManagementWebService.findAllPermission();
		permissionTree = JSONArray.fromObject(permissions).toString().replace("\"","\\\"" );

		return SUCCESS;
	}
	
	public void setPermissionTree(String permissionTree) {
		this.permissionTree = permissionTree;
	}

	public String getPermissionTree() {
		return permissionTree;
	}

}
